package File;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;

//利用Scanner获取文件数据
public class Demo8 {
    public static void main(String[] args) throws IOException {
//        Scanner scanner = new Scanner(System.in);//Scanner里面是一个InputStream对象
//        String s = scanner.next();
        try(InputStream  inputStream = new FileInputStream("./src/test.txt")){
            Scanner scanner = new Scanner(inputStream);
            String s = scanner.nextLine();//此时就是从文件中读取数据
            System.out.println(s);
        }

    }
}
